/*准备一个 HashMap 集合，统计字符串"123,456,789,123,456"中每个数字字符串出现的次数并打印出来。*/

import java.util.HashMap;
import java.util.Scanner;

public class Q3 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("请输入字符串:");
        //分割
        String[] splited = sc.next().split(",");

        HashMap<String, Integer> countMap = new HashMap<>();
        for(String ele: splited) {
            if (countMap.containsKey(ele)) {countMap.put(ele, countMap.get(ele)+1);}
            else {countMap.put(ele, 1);}
        }
        //打印

        for(String ele : countMap.keySet()) {
            System.out.println(ele+"出现了"+countMap.get(ele)+"次");
        }
    }
}
//123,456,789,123,456
//123,456,789,123,456,123,321,456